﻿using System;
using System.Windows.Forms;
using System.Xml;

namespace FormGUI
{
    public static class ReadFromXml
    {
        public static string HelpString
        {
            get;
            private set;
        }

        public static void Construct()
        {
            try
            {
                XmlDocument document = new XmlDocument();
                document.Load(@"help.xml");

                XmlNode node = document.DocumentElement.FirstChild;
                while (node != null)
                {
                    if (node.Name == "newline") HelpString += Environment.NewLine;
                    if (node.Name == "text") HelpString += node.InnerText + Environment.NewLine;
                    node = node.NextSibling;
                }
            }
            catch(Exception e)
            {
                string exceptionMessage = "XML file corrupted/not found !"+Environment.NewLine+e.Message;
                MessageBox.Show(exceptionMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }        
}
